package com.itheima.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.CompanyListDao;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.pojo.Company;
import com.itheima.service.CompanyListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service(interfaceClass = CompanyListService.class)
@Transactional
public class CompanyListServiceImpl implements CompanyListService {
    @Autowired
    private CompanyListDao companyListDao;
    @Override
    public PageResult pageQuery(QueryPageBean queryPageBean) {
        Integer currentPage = queryPageBean.getCurrentPage();
        Integer pageSize = queryPageBean.getPageSize();
        String queryString = queryPageBean.getQueryString();
        PageHelper.startPage(currentPage,pageSize);
        Page<Company> page= companyListDao.findByCondition(queryString);
//        Page<CheckGroup> page = checkGroupDao.findByCondition(queryString);
        PageResult ps = new PageResult(page.getTotal(), page.getResult());
        return ps;
    }

    @Override
    public void add(Company company) {
        companyListDao.add(company);
    }

    @Override
    public void delete(Integer id) {
        companyListDao.delete(id);
    }

    @Override
    public List<Company> findAll() {
        return  companyListDao.findAll();
    }

    @Override
    public String[] findAllAddress() {
        return  companyListDao.findAllAddress();

    }

    @Override
    public Company findAllAddress(String companyAddress) {
        return null;
    }
}
